import Vue from 'vue'
import router from './router'
import axios from 'axios';
import toast from './plugins/toast'
// let apiUrl='http://47.52.96.184:8081/index.php';
let apiUrl='http://192.168.33.10:8080/index.php';
// let scoketUrl='ws://47.52.96.184:9502';
let scoketUrl='ws://192.168.33.10:9502';
axios.defaults.baseURL = apiUrl
const parseUrlString=function (obj) {
  let data='';
  for (let [k,v] of Object.entries(obj)){
    data+=k+"="+v+'&';
  }
  return data.substring(0,data.length-1);
}

axios.interceptors.request.use(function (config) {
  // config.url=config.url.replace('index.php/?','index.php?')
  // config.url= config.url+urltoken;
  config.url=config.url.replace('index.php/?','index.php?')
  return config;
    return config;
}, function (error) {
  return Promise.reject(error);
});

axios.interceptors.response.use(function (response) {
  return response.data;
}, function (error) {
  toast.toast.warning('网络错误！')
  return Promise.reject(error);
});
// 你可以导出router


export default {apiUrl,parseUrlString,scoketUrl}
